﻿using System;
using System.Windows.Forms;
using bbtpClient.Entities;
using bbtpClient.Controllers;

namespace bbtpClient
{
    public partial class EditOrderListForm : Form
    {
        public EditOrderListForm(OrderHead[] orders)
        {
            InitializeComponent();
            label_UserName.Text = UserInfo.Name;
            orders_listBox.Items.AddRange(orders);
            orders_listBox.Invalidate();
        }

        private void editOrder_button_Click(object sender, EventArgs e)
        {
            int selectedOrderIndex = orders_listBox.SelectedIndex;
            OrderHead orderHead = (OrderHead)orders_listBox.Items[selectedOrderIndex];
            SalesmanController.ShowEditOrderForm(orderHead.id);
        }

        private void cancelOrder_button_Click(object sender, EventArgs e)
        {
            int selectedOrderIndex = orders_listBox.SelectedIndex;
            OrderHead orderHead = (OrderHead)orders_listBox.Items[selectedOrderIndex];
            SalesmanController.CancelOrder(orderHead.id, this);
        }

        public void RemoveSelectedOrder()
        {
            int selectedOrderIndex = orders_listBox.SelectedIndex;
            orders_listBox.Items.RemoveAt(selectedOrderIndex);
        }

        private void exit_button_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void label_UserRole_Click(object sender, EventArgs e)
        {

        }

        private void label_UserName_Click(object sender, EventArgs e)
        {

        }
    }
}